/**
 *  reg.h
 *
 *  Copyright (C) 2008  David Andrs <pda@jasnapaka.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef _REG_H_
#define _REG_H_

#define REG_KEY_COMPANY						L"Software\\DaProfik"
#define REG_KEY_APP							REG_KEY_COMPANY L"\\mLasq"
#define REG_KEY_CONFIGURATION				REG_KEY_APP L"\\Configuration"
#define REG_KEY_UI							REG_KEY_APP L"\\UI"

//

void RegWriteDword(HKEY hKey, LPCTSTR valueName, DWORD value);
void RegWriteString(HKEY hKey, LPCTSTR valueName, LPCTSTR value);
DWORD RegReadDword(HKEY hKey, LPCTSTR valueName, DWORD defaultValue);
CString RegReadString(HKEY hKey, LPCTSTR valueName, LPCTSTR defaultValue);

// CReg ///////////////

class CRegistry {
public:
	CRegistry(HKEY hRoot, const CString &regPath);
	virtual ~CRegistry();

	static void DeleteKey(HKEY hRoot, const CString &regPath);

	void Write(LPCTSTR valueName, BOOL value);
	void Write(LPCTSTR valueName, DWORD value);
	void Write(LPCTSTR valueName, UINT value);
	void Write(LPCTSTR valueName, LPCTSTR value);
	BOOL Read(LPCTSTR valueName, BOOL defaultValue);
	DWORD Read(LPCTSTR valueName, DWORD defaultValue);
	UINT Read(LPCTSTR valueName, UINT defaultValue);
	CString Read(LPCTSTR valueName, const CString &defaultValue);

	void QuerySubKeyNumber(LPDWORD lpcSubKeys);
	void QueryValueNumber(LPDWORD lpcValues, LPDWORD lpcbMaxValueNameLen = NULL);

	void DeleteValue(LPCTSTR valueName);

	void Close();

	operator HKEY() { return Key; }

protected:
//	CString RegPath;
//	HKEY RootKey;
	HKEY Key;
};


#endif
